home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Collections: Camelot
/
Camelot 098 (1990-12)(Swedish User Group of Amiga)(SE)(PD)[WB].zip
/
Camelot 098 (1990-12)(Swedish User Group of Amiga)(SE)(PD)[WB].adf
/
XLisp-Stat
/
Functions
/
newton.lsp
< prev
next >
Wrap
Lisp/Scheme
|
1990-10-11
|
489b
|
17 lines
; book p.107
(defun newton-search (f df guess)
(flet ((improve (guess)
(- guess (/ (funcall f guess) (funcall df guess))))
(good-enough-p (guess)
(< (abs (funcall f guess)) .001)))
(do ((guess guess (improve guess)))
((good-enough-p guess) guess))))
(defun make-derivative (f h)
#'(lambda (x)
(let ((fx+ (funcall f (+ x h)))
(fx- (funcall f (- x h)))
(2h (* 2 h)))
(/ (- fx+ fx-) 2h))))